package com.pat.java.swing.test;

import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;


//ToolbarFrame1.java
//A simple frame containing a "toolbar" made up of several java.awt.Button
//objects. We'll be converting the Buttons to JButtons in the ToolbarFrame2.java
//file.
//

public class ToolbarFrameWithAWT extends Frame{

	/**
	 * 
	 */
	private static final long serialVersionUID = -1744444021028840447L;
	
	Button cutButton, copyButton, pasteButton;
	public ToolbarFrameWithAWT(){
		super("Toolbar Example (AWT)");
		setSize(450,250);
		addWindowListener(new WindowAdapter(){
			@Override
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		});
		
		ActionListener printListener = new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent e) {
				System.out.println(e.getActionCommand());
			}
		};
		
		Panel toolbar = new Panel();
		toolbar.setLayout(new FlowLayout(FlowLayout.LEFT));
		
		cutButton = new Button("Cut");
		cutButton.addActionListener(printListener);
		toolbar.add(cutButton);
		
		copyButton = new Button("Copy");
		copyButton.addActionListener(printListener);
		toolbar.add(copyButton);
		
		pasteButton = new Button("Paste");
		pasteButton.addActionListener(printListener);
		toolbar.add(pasteButton);
		
		//The "preferred" BorderLayout add call
		add(toolbar, BorderLayout.NORTH);
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ToolbarFrameWithAWT tf1 =new ToolbarFrameWithAWT();
		tf1.setVisible(true);
	}

}
